
create table customer(id number primary key,name varchar2(20),sal number(10,2),birth Date,sex char,CONSTRAINT customer_name UNIQUE (name));
create sequence seq_customer_01 start with 1 increment by 1;
select * from customer;
select * from hobby;
create table hobby(id number primary key,name_id number,fav varchar2(20));
create sequence seq_hobby_01 start with 1 increment by 1;

alter table hobby
add constraint fk_name_id foreign key (name_id) 
references customer (id) on delete cascade;

insert into customer(id,name) values (seq_customer_01.nextval,'wyatt2');

drop table customer;
drop sequence seq_customer_01;
drop table hobby;
drop sequence seq_hobby_01;

drop table users;
drop table book;
drop table recording;
alter table recording drop constraint fk_user_id;
alter table recording drop constraint fk_book_id;

create table users (id char(40) primary key,name varchar2(20) not null,password varchar2(20) not null);
create table book (id char(40) primary key,name varchar2(20) not null,path varchar2(20) not null);
create table recording (id char(40) primary key,user_id char(40) not null,book_id  char(40) not null,order_time date);



alter table recording
add constraint fk_user_id foreign key (user_id) 
references users (id) on delete cascade;
alter table recording
add constraint fk_book_id foreign key (book_id) 
references book (id) on delete cascade;

alter table users modify id default 40;
alter table book modify id default 40;

insert into BOOK(id,name,path) values('c2f4b2d0c6274385be504ab2b582f120','Our Youth','images/book4.jpg');
insert into users(id,name,password) values('4bedbe4609674afab3ef5b0ff10c90a3','wyatt1','123456');

select * from BOOK;
select * from users;
select * from recording;